package cn.xiuxius.embedded.command.converter;
import cn.xiuxius.embedded.model.BooleanFlashOptionType;
import picocli.CommandLine;

public class BooleanTypeConverter implements CommandLine.ITypeConverter<BooleanFlashOptionType> {
    @Override
    public BooleanFlashOptionType convert(String value) {
        try {
            if (value == null || value.trim().isEmpty()) {
                return BooleanFlashOptionType.DEFAULT;
            }
            return BooleanFlashOptionType.from(value.trim().toUpperCase());
        } catch (Exception e) {
            throw new CommandLine.TypeConversionException("Invalid boolean value: " + value);
        }
    }
}
